﻿
$(function () {
    $Mrc.BaseAjax(ajaxType.get, "/Admin/Home/GetClientsDataJson", "", function (resp)
    {
        GetLoadNav(resp.data.authorizeMenu);
    });  
})

function GetLoadNav(Data) {
    var data = Data;
    var _html = "";
    var isfisrt = true;
    $.each(data, function (i) {
        var row = data[i];
        if (row.parentId == null) {
            if (row.type == 4)
            {//节点组
                _html += '<li data-name="' + row.name + '" class="layui-nav-item  ' + (isfisrt == true ? 'layui-nav-itemed' : '') + '">';
                _html += '<a href="javascript:;" lay-tips="' + row.name +'" lay-direction="2">';
                _html += '<i class="layui-icon layui-icon-home ' + row.icon+'"></i>';
                _html += '<cite>' + row.name + '</cite>';             
                _html += '</a>';
                var childNodes = row.children;
                if (childNodes.length > 0) {
                    _html += '<dl class="layui-nav-child">';
                    $.each(childNodes, function (i)
                    {
                        var subrow = childNodes[i];
                        var url = subrow.url || "";
                        _html += '<dd data-name="' + subrow.name +'"><a lay-href="' + url + '">' + subrow.name+'</a></dd>';                     
                    });
                    _html += '</dl>';
                }
                _html += '</li>';
                isfisrt = false;
            }
            else
            {
                _html += '<li data-name="' + row.name + '" class="layui-nav-item ' + (isfisrt ? 'layui-nav-itemed' : '') +'">';
                _html += '<a href="javascript:;" lay-tips="' + row.name + '" lay-direction="2">';
                _html += '<i class="layui-icon ' + row.icon + '"></i>';
                _html += '<cite>' + row.name + '</cite>';              
                _html += '</a>';
                _html += '</li>';
                isfisrt = false;
            }
        }
    });
    $("#LAY-system-side-menu").html(_html);
    layui.use('element', function () {
        var element = layui.element;
        element.init();
    });
}